#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	int m = 0, n = 0, d = 0, i = 0,count=0;
	double du = 0.0;
	scanf("%d %d", &m, &n);
	int(*arr1)[100] = calloc((m * 100), sizeof(int));
	int(*arr2)[100] = calloc((m * 100), sizeof(int));	
	for (i = 0; i < m; i++)
		for (d = 0; d < n; d++)
			scanf("%d", &arr1[i][d]);
	for (i = 0; i < m; i++)
		for (d = 0; d < n; d++)
			scanf("%d", &arr2[i][d]);
	for (i = 0; i < m; i++)
		for (d = 0; d < n; d++)
			if (arr1[i][d] == arr2[i][d])
				count++;
	du = (double)count / (double)(m * n);
	printf("%.2lf", du*100.0);
	return 0;
}